define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'jizhan.activity/index',
        add_url: 'jizhan.activity/add',
        edit_url: 'jizhan.activity/edit',
        delete_url: 'jizhan.activity/delete',
        export_url: 'jizhan.activity/export',
        modify_url: 'jizhan.activity/modify',
        activity_product_url: 'jizhan.activity_product/index',
    };
    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                cols: [[
                    {type: "checkbox"},
                    {field: 'id', width: 30, title: 'ID', search: 'no'},
                    {field: 'name', width: 150, title: '活动名称'},
                    {field: 'img', minWidth: 150, title: '活动图片', search: 'no', templet: ea.table.image},
                    {field: 'detail_page_img', minWidth: 100, title: '活动详情页-图片', search: 'no', templet: ea.table.image},
                    {field: 'start_time', minWidth: 150, title: '开始时间', search: 'no'},
                    {field: 'end_time', minWidth: 150, title: '结束时间', search: 'no'},
                    {field: 'status', minWidth: 100, title: '状态', selectList:{0:"关闭",1:"开始"}, templet: ea.table.switch},
                    {field: 'remark', minWidth: 100, title: '备注说明', search: 'no'},
                    {field: 'create_time', minWidth: 120, title: '创建时间', search: 'no'},
                    {width: 250, title: '操作', templet: ea.table.tool,
                        operat: [
                            [{
                                text: '活动商品配置',
                                url: init.activity_product_url,
                                method: 'open',
                                auth: 'stock',
                                class: 'layui-btn layui-btn-xs layui-btn-normal',
                            },{
                                text: '编辑',
                                url: init.edit_url,
                                method: 'open',
                                auth: 'edit',
                                class: 'layui-btn layui-btn-xs layui-btn-success',
                                extend: 'data-full="true"',
                            }],
                            'delete']
                    }
                ]],
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
    };
    return Controller;
});